﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lisp.Compiler
{
    internal class Add : ExecutableInstruction<Processor>
    {
        private IWriteInstruction<double, Processor> _output1 = new Processor.WriteInstruction();
        private IWriteInstruction<double, Processor> _output2 = new Processor.WriteInstruction();
        private IReadInstruction<double, Processor> _input = new Processor.ReadInstruction();

        public Add(Processor code) : base(code) { }

        public override void Execute(Processor code)
        {
            double a = _output1.Pop(code);
            double b = _output2.Pop(code);
            double c = a + b;
            _input.Push(code, c);
        }
    }
}
